//
//  BLShopingDetailViewController.m
//  blanket
//
//  Created by Mac on 2017/12/7.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "BLShopingDetailViewController.h"
#import "BLShopCarViewController.h"
#import "BLCustomModel.h"
#import "STAddressModel.h"
#import "BLGoodBuyViewController.h"
@interface BLShopingDetailViewController ()<STActionSheetDelegate>
@property(nonatomic, strong) STAddressModel                     *addModel;
@property(nonatomic, strong) STAdvertingScrollView               *adverView;
@property(nonatomic, strong) STLabel                        *titleLable;
@property(nonatomic, strong) STLabel                     *priceLable;//积分商城隐藏，采集商城展示
@property(nonatomic, strong) STLabel                         *desLable;
#pragma mark --bottom
@property(nonatomic, strong) STButton                     *shopButton;//购物车
@property(nonatomic, strong) STLabel                     *moneyLable;//金额
@property(nonatomic, strong) STButton                     *testButton;//线下送样
@property(nonatomic, strong) STButton                     *cofrimButton;//购买或者删除

@property(nonatomic, strong) NSArray                     *finshArray;

@property(nonatomic, strong) STActionSheet                     *pointActionSheet;//积分
@property(nonatomic, strong) STActionSheet                     *goodActionSheet;
@property(nonatomic, strong) STActionSheet                     *selfCustomActionSheet;
@end

@implementation BLShopingDetailViewController


#pragma mark --vc 生命周期
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"商品详情";
    UIView * tableFooter = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 49)];
    tableFooter.backgroundColor = self.tableView.backgroundColor;
    self.tableView.tableFooterView = tableFooter;
    [self configSubView];
    [self sendFetchDefultAddRequuest];
    // Do any additional setup after loading the view.
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self sendFetchDefultAddRequuest];
}
- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
}
- (void)configBootomeView{
    UIView  * bootomView = [[UIView alloc] initWithFrame:CGRectMake(0, [TMUtils tabbar].top, UIScreenWidth, [TMUtils tabbar].height)];
    bootomView.bottom = UIScreenHeight;
    bootomView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:bootomView];
    [bootomView st_showTopShadow];
    [bootomView st_showBottomLine];
    __weak typeof(self) weakSelf =  self;
    self.shopButton = [[STButton alloc] initWithFrame:CGRectMake(10, 0, 44, 49)
                                                title:@""
                                           titleColor:KL_firstTextColor
                                            titleFont:14
                                         cornerRadius:0
                                      backgroundColor:nil
                                      backgroundImage:nil
                                                image:[UIImage imageNamed:@"购物车"]];
    self.shopButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
    [self.shopButton setClicAction:^(UIButton *sender) {
        [weakSelf onSlectedShopCarButton];
    }];
    [bootomView addSubview:self.shopButton];
    
    self.cofrimButton = [[STButton alloc] initWithFrame:CGRectMake(0, 7, 80, 35)
                                                  title:@"立刻购买"
                                             titleColor:[UIColor whiteColor]
                                              titleFont:15
                                           cornerRadius:8
                                        backgroundColor:KL_BlueBackGroundColor
                                        backgroundImage:nil
                                                  image:nil];
    self.cofrimButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.cofrimButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelectedBuyButton];
    }];
    self.cofrimButton.right = UIScreenWidth - 10;
    [bootomView addSubview:self.cofrimButton];
    
    self.testButton = [[STButton alloc] initWithFrame:CGRectMake(0, 7, 100, 35)
                                                title:@"加入购物车"
                                           titleColor:[UIColor whiteColor]
                                            titleFont:15
                                         cornerRadius:8
                                      backgroundColor:KL_BlueBackGroundColor
                                      backgroundImage:nil
                                                image:nil];
    self.testButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.testButton setClicAction:^(UIButton *sender) {
        [weakSelf onSelectedAddCarButton];
    }];
    self.testButton.right = self.cofrimButton.left - 10;
    [bootomView addSubview:self.testButton];
    
    self.moneyLable = [[STLabel alloc] initWithFrame:CGRectMake(self.shopButton.right + 10, 0, self.testButton.left - self.shopButton.right - 20, 49)
                                                text:@"合计:$5698"
                                           textColor:KL_redColor
                                                font:13
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    self.moneyLable.text = [NSString stringWithFormat:@"合计:$%@",_model.price];
    self.moneyLable.attributedText = [self.moneyLable.text st_convertAttributeStringWithKeyWord:@"合计:"
                                                                                     attributes:@{NSForegroundColorAttributeName:KL_firstTextColor}];
   // [bootomView addSubview:self.moneyLable];
    
}
#pragma mark --subView
- (void)configSubView{
    [self configBootomeView];
    
    UIView * header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 100)];
    header.backgroundColor = [UIColor whiteColor];
    
    self.adverView = [[STAdvertingScrollView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 275) andWithArray:@[@"banner1",@"banner1",@"banner1",@"banner1",@"banner1"] handle:^(NSInteger num) {
        
    }];
    self.adverView.pageControll.bottom = self.adverView.height - 15;
    self.adverView.pageControll.currentPageIndicatorTintColor = [UIColor whiteColor];
    self.adverView.pageControll.pageIndicatorTintColor = KL_BlueBackGroundColor;
    self.adverView.pageControll.centerX = UIScreenWidth / 2;
    self.adverView.canAutoScroll = YES;
    self.adverView.time = 5;
    [header addSubview:self.adverView];
    self.adverView.imageUrlsArray = self.model.img_url_banner;
    
    self.titleLable = [[STLabel alloc] initWithFrame:CGRectMake(10, self.adverView.bottom +10, UIScreenWidth - 20, 40)
                                                     text:self.model.name
                                                textColor:BL_secendTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    self.titleLable.numberOfLines = 0;
    [header addSubview:self.titleLable];
    
    self.priceLable = [[STLabel alloc] initWithFrame:CGRectMake(0 + 10, self.titleLable.bottom, UIScreenWidth - 20 , 20)
                                                text:@"价格:￥456"
                                           textColor:BL_redColor
                                                font:14
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    [header  addSubview:self.priceLable];
    self.priceLable.text = [NSString stringWithFormat:@"会员价格:￥%@",_model.price];
    self.priceLable.attributedText = [self.priceLable.text st_convertAttributeStringWithKeyWord:@"会员价格:" attributes:@{NSForegroundColorAttributeName:BL_secendTextColor}];
    
    if ([self.model.type isEqualToString:@"2"]) {
        self.priceLable.hidden = YES;
    }
    
    self.desLable = [[STLabel alloc] initWithFrame:CGRectMake( 10, self.priceLable.bottom + 10, UIScreenWidth - 20 - 0, 20)
                                              text:@"50积分+60盖币"
                                         textColor:BL_secendTextColor
                                              font:14
                                       isSizetoFit:NO
                                     textAlignment:NSTextAlignmentLeft];
    self.desLable.text = [NSString stringWithFormat:@"积分价格:%@积分 + %@元",_model.score , _model.cap_coin];
    if ([self.model.type isEqualToString:@"2"]) {
        //积分商城，只有积分
        self.desLable.text = [NSString stringWithFormat:@"积分价格:%@积分",_model.score];
    }
    [header  addSubview:self.desLable];
//    self.model.intro = @"积分价格:%@积分 + %@元积分价格:%@积分 + %@元积分价格:%@积分 + %@元积分价格:%@积分 + %@元";
    NSString * htmlString = self.model.intro;
    NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
    
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(10, self.desLable.bottom, UIScreenWidth - 20, 20)
                                                     text:self.model.intro
                                                textColor:BL_secendTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    titleLable.attributedText = attrStr;
    [header addSubview:titleLable];
    
    [NSString lableAutoAdjustheightWithLabel:titleLable];
    
    UIView * line = [[UIView alloc] initWithFrame:CGRectMake(0, titleLable.bottom + 35, UIScreenWidth, 0.5)];
    line.backgroundColor = BL_lineColor;
    [header addSubview:line];
    
    UIView * titileView = [self headerViewWithTitle:@"商品详情"];
    titileView.top = line.bottom  +10;
    [header addSubview:titileView];
    
    //配置图片
    CGFloat top = titileView.bottom;
    for (int i =0; i < self.model.img_url.count; i ++) {
        UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, top, UIScreenWidth - 40, 375)];
        [imageView sd_setImageWithURL:[NSURL URLWithString:self.model.img_url[i]]];
        [header addSubview:imageView];
        top = imageView.bottom + 10;
    }
    header.height = top + 10;
    self.tableView.tableHeaderView = header;
    
}
- (UIView*)headerViewWithTitle:(NSString*)title{
    UIView * sectionHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UIScreenWidth, 44)];
    sectionHeader.backgroundColor = [UIColor whiteColor];
    STButton * line = [[STButton alloc] initWithFrame:CGRectMake(15, 0, 4, 22)
                                                title:nil
                                           titleColor:nil
                                            titleFont:14
                                         cornerRadius:0
                                      backgroundColor:BL_BlueBackGroundColor
                                      backgroundImage:nil
                                                image:nil];
    line.centerY = 22;
    [sectionHeader addSubview:line];
    STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(line.right + 20, 0, 200, 44)
                                                     text:title
                                                textColor:BL_firstTextColor
                                                     font:14
                                              isSizetoFit:NO
                                            textAlignment:NSTextAlignmentLeft];
    
    [sectionHeader addSubview:titleLable];
    return sectionHeader;
}
#pragma mark --Private Method
- (void)configGoddActionSheet{
    NSString * jifenzhifubao = [NSString stringWithFormat:@"您将支付宝支付￥%@元 + %@ 积分",
                                _model.cap_coin,
                                _model.score];
    NSString * jifenwechat = [NSString stringWithFormat:@"您将微信支付￥%@元 + %@ 积分",
                              _model.cap_coin,
                              _model.score];
    
    NSString * zhifubao = [NSString stringWithFormat:@"您将支付宝支付￥%0.2f 元",
                           _model.price.floatValue];
    NSString * wechat = [NSString stringWithFormat:@"您将微信支付￥%0.2f 元",
                         _model.price.floatValue];
    self.goodActionSheet = [[STActionSheet alloc] initWithTitle:@"支付方式"
                                                     buttonTitles:@[jifenzhifubao,jifenwechat,zhifubao,wechat]
                                                      cancelTitle:@"取消"
                                                         delegate:self];
    [self.goodActionSheet show];
}
- (void)configSlefCustomActionSheet{

    NSString * jifenzhifubao = [NSString stringWithFormat:@"您将支付宝支付￥%@元 + %@ 积分",
                                _model.cap_coin,
                                _model.score];
    NSString * jifenwechat = [NSString stringWithFormat:@"您将微信支付￥%@元 + %@ 积分",
                              _model.cap_coin,
                              _model.score];
    
    NSString * zhifubao = [NSString stringWithFormat:@"您将支付宝支付￥%0.2f 元",
                           _model.price.floatValue];
    NSString * wechat = [NSString stringWithFormat:@"您将微信支付￥%0.2f 元",
                         _model.price.floatValue];
    self.selfCustomActionSheet = [[STActionSheet alloc] initWithTitle:@"支付方式"
                                                   buttonTitles:@[jifenzhifubao,jifenwechat,zhifubao,wechat]
                                                    cancelTitle:@"取消"
                                                       delegate:self];
    [self.selfCustomActionSheet show];
}
- (void)configPointActionSheet{
    NSString * point = [NSString stringWithFormat:@"您将支付积分%@",self.model.score];
    self.pointActionSheet = [[STActionSheet alloc] initWithTitle:@"支付方式"
                                                    buttonTitles:@[point]
                                                     cancelTitle:@"取消"
                                                        delegate:self];
    [self.pointActionSheet show];
}
- (NSMutableDictionary *)defultDic{
    NSMutableDictionary * dic = [NSMutableDictionary new];
    [dic setObject:debugToken forKey:@"token"];
    BLShopModel *model = self.model;
    if ([STUserManger defult].userID.length) {
        [dic setObject:[STUserManger defult].userID forKey:@"uid"];
    }
    if (model.goodID.length) {
        [dic setObject:model.goodID forKey:@"gid"];
    }
    [dic setObject:@"1" forKey:@"num"];
    [dic setObject:@"4" forKey:@"goods_type"];
    if (model.score) {
        [dic setObject:model.score forKey:@"score"];
    }
    return dic;
}
//采集私人 字典
- (NSMutableDictionary *)defultGoodDic{
    NSMutableDictionary * dic = [NSMutableDictionary new];
    [dic setObject:debugToken forKey:@"token"];
    BLShopModel *model = self.model;
    if ([STUserManger defult].userID.length) {
        [dic setObject:[STUserManger defult].userID forKey:@"uid"];
    }
    if (model.goodID.length) {
        [dic setObject:model.goodID forKey:@"gid"];
    }
    [dic setObject:@"1" forKey:@"num"];
    if (model.score) {
        [dic setObject:model.score forKey:@"score"];
    }
    if (model.cap_coin) {
        [dic setObject:model.cap_coin forKey:@"grade"];
    }
    if (model.price) {
        [dic setObject:model.price forKey:@"money"];
    }
    return dic;
}
#pragma mark --Action Method
- (void)onSlectedShopCarButton{
    [self.navigationController pushViewController:[BLShopCarViewController new] animated:YES];
}
- (void)onSelectedAddCarButton{
    [self sendAddToCarShopRequest];
}
- (void)onSelectedBuyButton{
    BLShopCarModel * shopmodel = [BLShopCarModel new];
    shopmodel.name = _model.name;
    shopmodel.price = _model.price;
    shopmodel.num = @"1";
    shopmodel.make_score = @(_model.score.floatValue);
    shopmodel.score = @(_model.score.floatValue).description;
   // 1 采集，2积分.3私人定制
      //1洗涤2定制3积分4采集5私人
    if ([self.model.type isEqualToString:@"1"]) {
        shopmodel.type = @"4";
    }else if([self.model.type isEqualToString:@"2"]){
        shopmodel.type = @"3";
    }else if([self.model.type isEqualToString:@"3"]){
       shopmodel.type = @"5";
    }
    shopmodel.score_money = @(_model.cap_coin.integerValue);
    BLGoodBuyViewController  *goodBuy =  [BLGoodBuyViewController new];
    goodBuy.shopModel = shopmodel;
    goodBuy.allMoneyDesc = self.desLable.text;
    [self.navigationController pushViewController:goodBuy animated:YES];
}
- (void)judgeAndAleart{
    if ([self.model.type isEqualToString:@"1"]) {
        [self configGoddActionSheet];
    }else if([self.model.type isEqualToString:@"2"]){
        [self configPointActionSheet];
    }else if([self.model.type isEqualToString:@"3"]){
        [self configSlefCustomActionSheet];
    }
}
#pragma mark --STActionSheetDelegate
- (void)actionSheet:(STActionSheet *)actionSheet didClickedButtonAtIndex:(NSInteger)buttonIndex{

    if (actionSheet.titleArray.count <= buttonIndex) {
        //点击取消
        return;
    }
    
    if (self.pointActionSheet == actionSheet) {
        NSMutableDictionary * dic = [self defultDic];
        [dic setObject:@"3" forKey:@"goods_type"];//积分
        [self sendBuyNowRequest_version_twoWithDic:dic];
 
    }else if (self.goodActionSheet == actionSheet){
        NSMutableDictionary * dic = [self defultGoodDic];
        //积分 支付宝微信  -- 微信支付宝微信
         [dic setObject:@"4" forKey:@"goods_type"];//采集
        if (buttonIndex == 0) {
            [dic setObject:@"2" forKey:@"type"];
            [dic setObject:@"2" forKey:@"pay_type"];
        }
        if (buttonIndex == 1) {
            [dic setObject:@"2" forKey:@"type"];
            [dic setObject:@"3" forKey:@"pay_type"];
        }
        if (buttonIndex == 2) {
            [dic setObject:@"1" forKey:@"type"];
            [dic setObject:@"2" forKey:@"pay_type"];
        }
        if (buttonIndex == 3) {
             [dic setObject:@"1" forKey:@"type"];
            [dic setObject:@"3" forKey:@"pay_type"];
        }
        [self sendBuyNowUseMoneyRequest_version_twoWithDic:dic];
        
    }else if (self.selfCustomActionSheet == actionSheet){
        //私人定制
        NSMutableDictionary * dic = [self defultGoodDic];
        //积分 支付宝微信  -- 微信支付宝微信
        [dic setObject:@"5" forKey:@"goods_type"];//私人
        if (buttonIndex == 0) {
            [dic setObject:@"2" forKey:@"type"];
            [dic setObject:@"2" forKey:@"pay_type"];
        }
        if (buttonIndex == 1) {
            [dic setObject:@"2" forKey:@"type"];
            [dic setObject:@"3" forKey:@"pay_type"];
        }
        if (buttonIndex == 2) {
            [dic setObject:@"1" forKey:@"type"];
            [dic setObject:@"2" forKey:@"pay_type"];
        }
        if (buttonIndex == 3) {
            [dic setObject:@"1" forKey:@"type"];
            [dic setObject:@"3" forKey:@"pay_type"];
        }
        [self sendBuyNowUseMoneyRequest_version_twoWithDic:dic];
    }
    
}
#pragma mark --NetWork Method
- (void)sendAddToCarShopRequest{
    [SVProgressHUD showWithStatus:@"请稍后"];
    NSMutableDictionary * dic = [NSMutableDictionary new];
    [dic setObject:debugToken forKey:@"token"];
    NSString * url = [NSString stringWithFormat:@"%@%@",releaseServerUrlHeader,@"index.php/Api/Basics/shoppingCardAction"];
    if ([STUserManger defult].userID.length) {
        [dic setObject:[STUserManger defult].userID forKey:@"uid"];
    }
    BLShopModel * model = self.model;
    if (model.goodID) {
        [dic setObject:model.goodID forKey:@"gid"];
    }
    if ([self.model.type isEqualToString:@"1"]) {
         [dic setObject:@"4" forKey:@"type"];//采集
    }
    if ([self.model.type isEqualToString:@"2"]) {
        [dic setObject:@"3" forKey:@"type"];//积分
    }
    if ([self.model.type isEqualToString:@"3"]) {
        [dic setObject:@"5" forKey:@"type"];//积分
    }
    if (model.name.length) {
        [dic setObject:model.name forKey:@"name"];
    }
    if (model.price) {
        [dic setObject:model.price forKey:@"price"];
    }
    [dic setObject:@"1"forKey:@"num"];


    if (model.score.length) {
        [dic setObject:model.score forKey:@"score"];
    }
    if (model.cap_coin.length) {
        [dic setObject:model.cap_coin forKey:@"cap_coin"];
    }
    
    //新家三个字段
    if (model.cap_coin) {
        [dic setObject:model.cap_coin forKey:@"score_money"];
    }
    if (model.score) {
        [dic setObject:model.score forKey:@"make_score"];
    }
    [dic setObject:@"0" forKey:@"grade"];
    
    [[STNetWrokManger defaultClient] requestWithPath:url
                                              method:STHttpRequestTypePost
                                          parameters:dic
                                             success:^(NSURLSessionDataTask *operation, id responseObject) {
                                                 [self.tableView.mj_header endRefreshing];
                                                 [SVProgressHUD dismiss];
                                                 [SVProgressHUD showSuccessWithStatus:@"添加到购物车成功"];
                                                 
                                             } failure:^(NSString *stateCode, STError *error) {
                                                 [self.tableView.mj_header endRefreshing];
                                                 [SVProgressHUD dismiss];
                                                 [SVProgressHUD showErrorWithStatus:error.desc];
                                             }];
}
//立刻购买  - 积分商城 - 扣除积分
- (void)sendBuyNowRequest_version_twoWithDic:(NSMutableDictionary*)dic{
    NSString * url = [NSString stringWithFormat:@"%@%@",releaseServerUrlHeader,@"index.php/Api/Basics/goodsScoreAction"];
    if (self.addModel) {
        if (self.addModel.address.length) {
            [dic setObject:self.addModel.address forKey:@"address"];
        }
        if (self.addModel.mobile.length) {
            [dic setObject:self.addModel.mobile forKey:@"mobile"];
        }
        if (self.addModel.username.length) {
            [dic setObject:self.addModel.username forKey:@"username"];
        }
    }
    [[STNetWrokManger defaultClient] requestWithPath:url
                                              method:STHttpRequestTypePost
                                          parameters:dic
                                             success:^(NSURLSessionDataTask *operation, id responseObject) {
                                                 [self.tableView.mj_header endRefreshing];
                                                 [SVProgressHUD dismiss];
                                                 [SVProgressHUD showSuccessWithStatus:@"购买成功"];
                                                 [self.navigationController popViewControllerAnimated:YES];
                                                 
                                             } failure:^(NSString *stateCode, STError *error) {
                                                 [self.tableView.mj_header endRefreshing];
                                                 [SVProgressHUD dismiss];
                                                 [SVProgressHUD showErrorWithStatus:error.desc];
                                             }];
}
//立刻购买  - 采集商城 - 私人
- (void)sendBuyNowUseMoneyRequest_version_twoWithDic:(NSMutableDictionary*)dic{
     NSString * type = dic[@"pay_type"];
    NSString * url = [NSString stringWithFormat:@"%@%@",releaseServerUrlHeader,@"index.php/Api/Basics/goodsBuyAction"];
    if (self.addModel) {
        if (self.addModel.address.length) {
            [dic setObject:self.addModel.address forKey:@"address"];
        }
        if (self.addModel.mobile.length) {
            [dic setObject:self.addModel.mobile forKey:@"mobile"];
        }
        if (self.addModel.username.length) {
            [dic setObject:self.addModel.username forKey:@"username"];
        }
    }
    [[STNetWrokManger defaultClient] requestWithPath:url
                                              method:STHttpRequestTypePost
                                          parameters:dic
                                             success:^(NSURLSessionDataTask *operation, id responseObject) {
                                                 [SVProgressHUD dismiss];
                                                 NSString * order =  responseObject[@"data"];
                                                 if([type isEqualToString:@"2"]){
                                                     //支付宝
                                                     [TMUtils sendAliPayWithOrder:order];
                                                     
                                                 }else if([type isEqualToString:@"3"]){
                                                     //微信
                                                     [TMUtils sendWechatPayWithOrder:order];
                                                     
                                                 }
                                                 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                                                   //  [self.navigationController popViewControllerAnimated:YES];
                                                 });
                                                 
                                                 
                                             } failure:^(NSString *stateCode, STError *error) {
                                                 [SVProgressHUD dismiss];
                                                 [SVProgressHUD showErrorWithStatus:error.desc];
                                             }];
    
}
- (void)sendFetchDefultAddRequuest{
    NSMutableDictionary * dic = [NSMutableDictionary new];
    [dic setObject:debugToken forKey:@"token"];
    NSString * url = [NSString stringWithFormat:@"%@%@",releaseServerUrlHeader,@"index.php/Api/Basics/userDefaultAddress"];
    if ([STUserManger defult].userID.length) {
        [dic setObject:[STUserManger defult].userID forKey:@"uid"];
    }
    [[STNetWrokManger defaultClient] requestWithPath:url
                                              method:STHttpRequestTypePost
                                          parameters:dic
                                             success:^(NSURLSessionDataTask *operation, id responseObject) {
                                                 [SVProgressHUD dismiss];
                                                 NSString * modelDic =  responseObject[@"data"];
                                                 self.addModel = [STAddressModel mj_objectWithKeyValues:modelDic];
                                                 
                                             } failure:^(NSString *stateCode, STError *error) {
                                                 [SVProgressHUD dismiss];
                                                 [SVProgressHUD showErrorWithStatus:error.desc];
                                             }];
}
@end
